/**
* @description: 剑指 Offer 46. 把数字翻译成字符串
* @author hewei
* @date 2022/7/22 20:21
* @version 1.0
*/

public class TranslateNum {

    public int translateNum(int num) {
        String s = String.valueOf(num);
        int one = 1;
        int two = 1;
        for (int i = 1; i < s.length(); i++) {
            int temp = two;
            char c1 = s.charAt(i - 1);
            char c2 = s.charAt(i);
            if ((c1 == '1') || (c1 == '2' && c2 < '6')) two += one;
            one = temp;
        }
        return two;
    }
}
